//
//  Connect.m
//  grainHouse
//
//  Created by 北风 on 14-10-14.
//  Copyright (c) 2014年 北风. All rights reserved.
//

#import "Connect.h"
#import "AFHTTPRequestOperationManager.h"

@implementation Connect
- (void)dealloc
{
    Block_release(_Myblock);
    [super dealloc];
}
-(void)connectWithUrl:(NSString *)url pramter:(NSDictionary *)dic passValue:(Block)block{
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    
    //https解密
    manager.securityPolicy.allowInvalidCertificates = YES;
    
    //json序列化器   遇到这样的格式返回数据
    [manager.responseSerializer setAcceptableContentTypes:[NSSet setWithObjects:@"text/json",@"application/json",@"text/javascript",@"text/html",@"text/css", nil]];
    
    
    [manager GET:url parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
    
        NSDictionary *dic = [operation.response allHeaderFields];
        NSLog(@"服务器信息%@",dic);
        self.Myblock = block;
        self.Myblock(responseObject);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        
    }];
    
    
}


@end
